#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for proftpd on Debian. Place in /etc/init.d and
# run 'update-rc.d -f proftpd defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add proftpd'

### BEGIN INIT INFO
# Provides:          proftpd
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the proftpd server
# Description:       starts proftpd using start-stop-daemon
### END INIT INFO

# Author:   Xiao Dong
# website:  http://lnmt.org

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="proftpd daemon"
NAME=proftpd
DAEMON=/usr/local/proftpd/sbin/$NAME
CONFIGFILE=/usr/local/proftpd/etc/$NAME.conf
PIDFILE=/usr/local/proftpd/var/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
 $DAEMON || echo -n "$NAME already running"
}

do_stop() {
 kill -INT `cat $PIDFILE` || echo -n "$NAME not running"
}

do_reload() {
 kill -HUP `cat $PIDFILE` || echo -n "$NAME can't reload"
}

case "$1" in
 start)
 echo -n "Starting $DESC: $NAME"
 do_start
 echo "."
 ;;
 stop)
 echo -n "Stopping $DESC: $NAME"
 do_stop
 echo "."
 ;;
 restart)
 echo -n "Restarting $DESC: $NAME"
 do_stop
 do_start
 echo "."
 ;;
 reload)
 echo -n "Stopping $DESC: $NAME"
 do_reload
 echo "."
 ;;
 *)
 echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
 exit 3
 ;;
esac

exit 0
